package tralala.jdo;

import java.io.Serializable;

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Transaction;

import tralala.data.*;

public class CantanteDAO {
	
	
private PersistenceManager pm = null;
private PersistenceManagerFactory pmf=null;
private static CantanteDAO cd= new CantanteDAO();

private CantanteDAO(){
	System.out.println("Constructor CantanteDAO");
	pmf = JDOHelper.getPersistenceManagerFactory("datanucleus.properties");
	pm=pmf.getPersistenceManager();
}

public static CantanteDAO getInstance(){
	return cd;
}
	
	public void almacenar(Cantante c){
		Transaction tx = pm.currentTransaction();
		tx.begin();
		pm.makePersistent(c);
		tx.commit();
	}
	
	public void eliminar(Cantante c){
		Transaction tx = pm.currentTransaction();
		tx.begin();
		pm.deletePersistent(c);
		tx.commit();
	}
	
	

}
